package com.tms.employee.controller;

import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.PutObjectResult;
import com.tms.employee.domain.TmsEmployee;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.employee.service.ITmsEmployeeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 员工管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/employee")
public class TmsEmployeeController extends BaseController
{
    @Autowired
    private ITmsEmployeeService tmsEmployeeService;

    /**
     * 查询员工管理列表
     */
    @RequiresPermissions("employee:employee:list")
    @GetMapping("/list")
    public TableDataInfo list(TmsEmployee tmsEmployee)
    {
        startPage();
        List<TmsEmployee> list = tmsEmployeeService.selectTmsEmployeeList(tmsEmployee);
        return getDataTable(list);
    }

    /**
     * 导出员工管理列表
     */
    @RequiresPermissions("employee:employee:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, TmsEmployee tmsEmployee)
    {
        List<TmsEmployee> list = tmsEmployeeService.selectTmsEmployeeList(tmsEmployee);
        ExcelUtil<TmsEmployee> util = new ExcelUtil<TmsEmployee>(TmsEmployee.class);
        util.exportExcel(response, list, "员工管理数据");
    }

    /**
     * 获取员工管理详细信息
     */
    @RequiresPermissions("employee:employee:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tmsEmployeeService.selectTmsEmployeeById(id));
    }

    /**
     * 新增员工管理
     */
    @RequiresPermissions("employee:employee:add")
    @PostMapping
    public AjaxResult add(@RequestBody TmsEmployee tmsEmployee)
    {
        tmsEmployee.setCreationTime(new Date());
        tmsEmployee.setCreator("admin");
        return toAjax(tmsEmployeeService.insertTmsEmployee(tmsEmployee));
    }

    /**
     * 修改员工管理
     */
    @RequiresPermissions("employee:employee:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody TmsEmployee tmsEmployee)
    {
        return toAjax(tmsEmployeeService.updateTmsEmployee(tmsEmployee));
    }

    /**
     * 删除员工管理
     */
    @RequiresPermissions("employee:employee:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tmsEmployeeService.deleteTmsEmployeeByIds(ids));
    }





}
